Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛(api) fix not thread-safe database session singleton #131

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

jmaupetit
Copy link
Member

Purpose

The singleton pattern is not thread-safe leading to database session inconsistency during server heavy load (expired sessions, etc.)

See raised errors in SQLAlchemy docuementation: https://docs.sqlalchemy.org/en/20/errors.html#error-bhk3

Proposal

Get a new session everytime it needs to be injected. Hope this won't create too many database connections.

@jmaupetit jmaupetit self-assigned this Jul 19, 2024
@jmaupetit jmaupetit added bug Something isn't working improvement API Item related to the API service labels Jul 19, 2024
The singleton pattern is not thread-safe leading to database session
inconsistency during server heavy load (expired sessions, etc.)

See raised errors in SQLAlchemy docuementation:
https://docs.sqlalchemy.org/en/20/errors.html#error-bhk3
@jmaupetit jmaupetit force-pushed the api-improve-db-session-management branch from c692105 to a07c905 Compare July 19, 2024 14:58
@jmaupetit jmaupetit merged commit 9be3357 into main Jul 19, 2024
12 checks passed
@jmaupetit jmaupetit deleted the api-improve-db-session-management branch July 19, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Item related to the API service bug Something isn't working improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant